<template>
	<view class="container">
		<view class="content">
			<header-view></header-view>
			<view class="add flex_center" @tap="addPath">
				<uni-icons type="plusempty" size="22" style="font-weight: 600;"></uni-icons>
			</view>
			<view class="title">加密钱包</view>
			<view class="list">
				<view class="item flex" v-for="item in list" :key="item.address">
					<image class="item_logo" :src="item.image" mode="widthFix"></image>
					<view class="detail font_title" @tap="addPath(item,'detail')">
						<view class="item_name">{{item.main}}</view>
						<view class="item_number flex">
							<text
								style="font-size: 34rpx;line-height: 34rpx;transform: translateY(2px);">{{item.address}}</text>
							<view style="width:19px;height: 19px;" @tap.stop="copy(item)">
								<uni-icons custom-prefix="iconfont" type="icon-fuzhi" size="19"
									style="opacity: 0.3;margin-left: 10rpx;"></uni-icons>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import headerView from "@/components/headerView.vue"
	import {
		walletListApi,
	} from "@/api/api.js"
	export default {
		components: {
			headerView
		},
		data() {
			return {
				list: []
			};
		},
		onShow() {
			this.getList()
		},
		methods: {
			getList() {
				const token = uni.getStorageSync('token');
				const type = '2';
				walletListApi({
					token,
					type
				}).then(res => {
					this.list = res.data.data
					console.log(this.list)
				})
			},
			addPath(opt, type) {
				if (type == "detail") {
					console.log(opt.id)
					uni.navigateTo({
						url: "/pages/user/wallet/addCrypto?id=" + opt.id
					})
				} else {
					uni.navigateTo({
						url: "/pages/user/wallet/addCrypto"
					})
				}

			},
			copy(opt) {
				console.log(opt.address)
				uni.setClipboardData({
					data: opt.address,
					success: () => {
						uni.$u.toast("复制成功")
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		.content {
			padding-bottom: 40rpx;
			position: relative;

			.add {
				position: absolute;
				right: 40rpx;
				top: 40rpx;
				width: 72rpx;
				height: 72rpx;
				background-color: hsla(0, 0%, 92.9%, .46);
				border-radius: 20rpx;
			}

			.title {
				padding-top: 60rpx;
				font-size: 30px;
				font-weight: 500;
				font-family: PM;
				line-height: 92rpx;
			}

			.list {
				margin-top: 40rpx;

				.item {
					align-items: flex-start;

					.item_logo {
						width: 90rpx;
						height: 90rpx;
						overflow: hidden;
						border-radius: 50%;
						box-shadow: 0 6rpx 16rpx 0 rgba(0, 0, 0, .16)
					}

					.detail {
						flex: 1;
						padding: 30rpx;
						border-radius: 30rpx;
						box-shadow: 0 6rpx 16rpx 0 rgba(0, 0, 0, .16);
						margin-left: 30rpx;
						font-weight: 600;

						.item_name {
							opacity: .5;
						}
					}
				}
			}
		}
	}
</style>